//
//  WMEOneInformationCollectionViewCell.m
//  WMEMusic
//
//  Created by 恩叔 on 16/4/12.
//  Copyright © 2016年 enshu. All rights reserved.
//

#import "WMEOneInformationCollectionViewCell.h"

@interface WMEOneInformationCollectionViewCell ()
@property (nonatomic, strong)UIImageView *pic;
@property (nonatomic, strong)UILabel *titleLabel;
@end

@implementation WMEOneInformationCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.pic = [[UIImageView alloc] init];
//        _pic.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_pic];
        
        self.titleLabel = [[UILabel alloc] init];
//        _titleLabel.backgroundColor = [UIColor cyanColor];
        _titleLabel.font = [UIFont systemFontOfSize:11];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
    }
    return self;
}
- (void)setModel:(WMEFirstPageModel *)model
{
    if (_model != model) {
        _model = model;
        [_pic sd_setImageWithURL:[NSURL URLWithString:_model.pic_300]];
        _titleLabel.text = [NSString stringWithFormat:@"%@", _model.title];
        NSLog(@"%@", model.listid);
    }
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    WS(ws);
    [super applyLayoutAttributes:layoutAttributes];
    [_pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws).with.offset(3);
        make.top.equalTo(ws).with.offset(3);
        make.right.equalTo(ws).with.offset(-3);
        make.height.equalTo(_pic.mas_width);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_pic.mas_bottom).with.offset(0);
        make.left.equalTo(ws.mas_left).with.offset(3);
        make.right.equalTo(ws.mas_right).with.offset(-3);
        make.bottom.equalTo(ws.mas_bottom).with.offset(-3);
    }];
}
@end
